package com.tllq.zhongkang.controller;

import com.tllq.zhongkang.entity.Order;
import com.tllq.zhongkang.entity.ResultMap;
import com.tllq.zhongkang.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class OrderController {
    Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    OrderService orderService;

    @GetMapping("/order")
    public ResultMap order(String startTime, String endTime){
        ResultMap res = null;
        if (StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)){
            res=ResultMap.error("参数不能为空");
            logger.error("/order"+res);
            return res;
        }
        logger.info("==========startTime:{},===========endTime:{}",startTime,endTime);
        List<Order> orders = orderService.findOrderByTime(startTime, endTime);
        return ResultMap.ok(orders);
    }




}
